home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / MATRIX04.ARJ / MATTRAN.C < prev    next >
C/C++ Source or Header  |  1992-05-22  |  1KB  |  46 lines

  1. /*
  2. *-----------------------------------------------------------------------------
  3. *    file:    mattran.c
  4. *    desc:    matrix mathematics
  5. *    by:    ko shu pui, patrick
  6. *    date:    v0.1 - 24 nov 91
  7. *    revi:    v0.2 - 14 may 92
  8. *    ref:
  9. *       [1] Mary L.Boas, "Mathematical Methods in the Physical Sciene,"
  10. *    John Wiley & Sons, 2nd Ed., 1983. Chap 3.
  11. *
  12. *-----------------------------------------------------------------------------
  13. */
  14.  
  15. #include <stdio.h>
  16. #include "matrix.h"
  17.  
  18. /*
  19. *-----------------------------------------------------------------------------
  20. *    funct:    mat_tran
  21. *    desct:    transpose of a matrix
  22. *    given:    A = matrix A to be transposed
  23. *    retrn:    allocated matrix for A^t
  24. *    comen:
  25. *-----------------------------------------------------------------------------
  26. */
  27. MATRIX mat_tran( A )
  28. MATRIX A;
  29. {
  30.     int    i, j;
  31.     MATRIX    At;
  32.  
  33.     if ((At = mat_creat( MatCol(A), MatRow(A), UNDEFINED )) == NULL)
  34.         return (NULL);
  35.  
  36.     /*
  37.     *    Transposing ...
  38.     */
  39.     for (i=0; i<MatCol(A); i++)
  40.     for (j=0; j<MatRow(A); j++)
  41.         {
  42.         At[i][j] = A[j][i];
  43.         }
  44.     return (At);
  45. }
  46.